﻿using System;

namespace Pdelvo.Minecraft.Protocol
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    public class PacketException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PacketException"/> class.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <remarks></remarks>
        public PacketException(byte code)
        {
            Code = code;
        }

        /// <summary>
        /// Gets or sets the code.
        /// </summary>
        /// <value>The code.</value>
        /// <remarks></remarks>
        public byte Code { get; set; }

        /// <summary>
        /// Gets the help code.
        /// </summary>
        /// <remarks></remarks>
        public string HelpCode
        {
            get { return string.Format("Packet Exception [0x{0:X2}]", Code); }
        }

        /// <summary>
        /// Ruft eine Meldung ab, die die aktuelle Ausnahme beschreibt.
        /// </summary>
        /// <returns>Die Fehlermeldung, die die Ursache der Ausnahme erklärt, bzw. eine leere Zeichenfolge ("").</returns>
        /// <remarks></remarks>
        public override string Message
        {
            get { return string.Format("Packet Exception [0x{0:X2}]", Code); }
        }
    }
}